package thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPool {
    private static ExecutorService pool1 = Executors.newFixedThreadPool(5);
    private static ExecutorService pool2 = new ThreadPoolExecutor(5, 10, 0, TimeUnit.MILLISECONDS,
            new LinkedBlockingDeque<>());

    public static void main(String[] args) {
        Runnable task = () -> {
            for (int i = 0; i < 10; i++) {
                System.out.print(i + " ");
            }
        };
        pool1.submit(task);
        pool2.submit(task);
        pool1.shutdown();
        pool2.shutdown();
    }
}
